package cn.edu.lingnan.servlet.student;

import cn.edu.lingnan.service.StudentService;
import cn.edu.lingnan.service.StudentServiceMysqlImpl;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

@WebServlet("/admin/student/delStu")
public class DeleteStudentServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String sid=req.getParameter("sid");
        System.out.println("[DEBUG 060]学号数组为:"+sid);
        StudentService service=new StudentServiceMysqlImpl();
        String[] allsid=sid.split(",");
        for(String onesid:allsid){
            System.out.println("[DEBUG 061]删除的学生学号为:["+onesid+"]");
            service.deleteStudentBySid(onesid);
        }
        resp.sendRedirect("/student/queryAllStu");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
